// Copyright (C) joyinter
// All rights reserved.
// 
// Author : Jiang Li
// Date   : 2004-9-30

#ifndef __ROOMINDEX_H_CLIENT_MAIN__
#define __ROOMINDEX_H_CLIENT_MAIN__

#pragma once
#include <common\ui\wnd.h>
#include <common\ui\listview.h>

class CJoyRI_List;
class CJoyRI_Group;
class CJoyRI_Item;
class CJoyRoomIndex;

namespace JoyRI_Fields
{
class RoomNameField;
class PrizeField;
class CreditField;
class UserLevelField;
class UserNowField;
class NetworkField;
};

//##ModelId=44C4B5DF02FD
class CJoyRI_Item : public CJoyListViewItem
{
public:
	//##ModelId=44C4B5DF030F
    CStringW m_roomName;
	//##ModelId=44C4B5DF0313
    CString m_serverIP;
	//##ModelId=44C4B5DF031C
    UINT    m_roomId;
	//##ModelId=44C4B5DF031D
    UINT    m_userLevel;
	//##ModelId=44C4B5DF031E
    UINT    m_userNow;
	//##ModelId=44C4B5DF032C
    UINT    m_userMax;
	//##ModelId=44C4B5DF032D
    UINT    m_serverPort;
	//##ModelId=44C4B5DF032E
    UINT    m_gameId;
	//##ModelId=44C4B5DF033C
    int     m_network;
	//##ModelId=44C4B5DF033D
    int     m_prize;
	//##ModelId=44C4B5DF033E
    int     m_credit;

	//##ModelId=44C4B5DF033F
    void DrawSixPoint(Graphics& graph, Brush& brush, int x);
	//##ModelId=44C4B5DF034E
    virtual void CM_Draw(Graphics& graph);
	//##ModelId=44C4B5DF035D
    virtual void CM_Mouse(MouseMessage msg, const CPoint& pt);
public:
	//##ModelId=44C4B5DF036B
    CJoyRI_Item();
	//##ModelId=44C4B5DF036C
    virtual ~CJoyRI_Item();
};

//##ModelId=44C4B5DF037A
class CJoyRI_Field : public CJoyListViewField
{
protected:
	//##ModelId=44C4B5DF038B
    virtual void CM_Draw(Graphics& graph);
public:
};

//##ModelId=44C4B5DF03A9
class CJoyRI_List : public CJoyListView
{
	DECLARE_DYNAMIC(CJoyRI_List)
public:
	//##ModelId=44C4B5DF03BA
    CJoyRI_Field*   m_infoField;
	//##ModelId=44C4B5DF03BF
    CJoyRoomIndex*  m_roomIndex;
    // fields.
	//##ModelId=44C4B5DF03C4
    JoyRI_Fields::RoomNameField*  m_roomNameField;
	//##ModelId=44C4B5DF03C9
    JoyRI_Fields::PrizeField*     m_prizeField;
	//##ModelId=44C4B5DF03CE
    JoyRI_Fields::CreditField*    m_creditField;
	//##ModelId=44C4B5DF03D3
    JoyRI_Fields::UserLevelField* m_userLevelField;
	//##ModelId=44C4B5DF03D9
    JoyRI_Fields::UserNowField*   m_userNowField;
	//##ModelId=44C4B5DF03DE
    JoyRI_Fields::NetworkField*   m_networkField;

	//##ModelId=44C4B5E00000
    CJoyRI_List();
	//##ModelId=44C4B5E00001
    virtual ~CJoyRI_List();

	//##ModelId=44C4B5E00003
    void ReBuildNameFieldSize();

public:
    DECLARE_MESSAGE_MAP()
	//##ModelId=44C4B5E00004
    afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
};

//##ModelId=44C4B5E0001F
class CJoyRI_Group : public CJoyWnd
{
protected:

	//##ModelId=44C4B5E0002E
    virtual void CM_Mouse(MouseMessage msg, const CPoint& pt);
	//##ModelId=44C4B5E00032
    virtual void CM_Draw(Graphics& graph);
public:
	//##ModelId=44C4B5E0003F
    CStringW    m_title;

	//##ModelId=44C4B5E00044
    CJoyRoomIndex*  m_roomIndex;
	//##ModelId=44C4B5E00049
    CJoyRI_List*    m_roomList;

	//##ModelId=44C4B5E00051
    CJoyRI_Group();
	//##ModelId=44C4B5E00052
    virtual ~CJoyRI_Group();
};

//##ModelId=44C4B5E0006D
class CJoyRoomIndex :
    public CJoyWnd
{
	DECLARE_DYNAMIC(CJoyRoomIndex)
protected:
	//##ModelId=44C4B5E0007F
    CJoyXmlElement* m_listSkin;
	//##ModelId=44C4B5E00084
    CList<CJoyRI_Group*>    m_groups;
	//##ModelId=44C4B5E0008D
    CJoyRI_Group* m_selGroup;

	//##ModelId=44C4B5E00091
    void SplitGroup(CJoyRI_Group* g);

	//##ModelId=44C4B5E0009D
    virtual void CM_LoadSkin(CJoyXmlElement* pSkinElem);

public:

	//##ModelId=44C4B5E000AE
    CJoyImagePtr    m_roomIcon;

public:
	//##ModelId=44C4B5E000B2
    CJoyRoomIndex(void);
	//##ModelId=44C4B5E000BB
    virtual ~CJoyRoomIndex(void);

	//##ModelId=44C4B5E000BE
    CJoyRI_Group* AddGroup(const CString& title);
	//##ModelId=44C4B5E000C0
    void SelectGroup(CJoyRI_Group* g, bool sel);

	//##ModelId=44C4B5E000CC
    void ReBuildNameFieldSize();
	//##ModelId=44C4B5E000CD
    void ReBuildGroup(CList<CJoyListViewItem*>& items);
	//##ModelId=44C4B5E000CF
    CJoyImagePtr& GetNetIcon(int network);
	//##ModelId=44C4B5E000DA
    void ValidateFieldsByGameId(UINT gameId);

public:
    DECLARE_MESSAGE_MAP()
	//##ModelId=44C4B5E000DC
    afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
};

#endif  // __ROOMINDEX_H_CLIENT_MAIN__
